package com.lone.smallmovie.utils.framework;

import com.lone.smallmovie.utils.LoginSession;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;
import java.util.Map;


public class SessionListener implements HttpSessionListener{
	
	
	private static Log log = LogFactory.getLog(SessionListener.class);

	public void sessionCreated(HttpSessionEvent arg0) {
	}

	public void sessionDestroyed(HttpSessionEvent arg0) {
		log.info("session 销毁:" + arg0.getSession().getAttribute("id"));
		
		@SuppressWarnings("unchecked")
		Map<String, String> user = (Map<String, String>)arg0.getSession().getAttribute("id");
		
		if (user != null)
		{
			LoginSession.removeUserSession(user.get("id"));
		}
	}
}
